package tag

import org.apache.commons.lang.StringUtils
import org.apache.spark.broadcast.Broadcast
import org.apache.spark.sql.Row

object AppTags extends Tags {
  override def makeTags(args: Any*): List[(String, Int)] = {
    val row = args(0).asInstanceOf[Row]
    val dictBc = args(1).asInstanceOf[Broadcast[Map[String,String]]]
    var list = List[(String,Int)]()
    //app
    var appName = row.getAs[String]("appname")
    val appId = row.getAs[String]("appid")
    if (StringUtils.isEmpty(appName)) {
      if (StringUtils.isNotEmpty(appId)) {
        appName = dictBc.value.getOrElse(appId, appId)
        list :+= ("APP" + appName, 1)
      }
    } else {
      list :+= ("APP" + appName, 1)
    }
    list
  }
}
